#include "stdafx.h"
#include "QtWidgetsApplication.h"
#include <QtWidgets/QApplication>
#include <iostream>
#include <MainWindowT.h>


void ShowMenu() {
    std::wcout << L"\n========== 桌面图标整理工具 ==========\n";
    std::wcout << L"1. 扫描桌面文件\n";
    std::wcout << L"2. 按类型整理(显示)\n";
    std::wcout << L"3. 按名称排序\n";
    std::wcout << L"4. 按大小排序\n";
    std::wcout << L"5. 按修改时间排序\n";
    std::wcout << L"6. 按扩展名整理\n";
    std::wcout << L"7. 显示统计信息\n";
    std::wcout << L"8. 创建分类文件夹\n";
    std::wcout << L"9. 移动文件到分类文件夹\n";
    std::wcout << L"0. 退出\n";
    std::wcout << L"请选择操作: ";
}

void ClearScreen() {
    system("cls");
}

void Pause() {
    std::wcout << L"\n按回车键继续...";
    std::cin.ignore();
    std::cin.get();
}
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
    /*MainWindow window;        // 创建主窗口对象
    window.show();*/
    //// 设置控制台输出为UTF-8，支持中文
    SetConsoleOutputCP(65001);
    SetConsoleCP(65001);
  
    QtWidgetsApplication organizer;
    int choice = 0;

    std::wcout << L"桌面图标整理工具 - VS2022 版本\n";
    std::wcout << L"初始化..." << (organizer.Initialize() ? L"成功" : L"失败") << L"\n";

    do {
        ClearScreen();
        ShowMenu();
        std::cin >> choice;

        switch (choice) {
        case 1:
            if (organizer.ScanDesktopFiles()) {
                std::wcout << L"\n扫描到 " << organizer.GetFileCount() << L" 个文件\n";
            }
            else {
                std::wcout << L"扫描失败!\n";
            }
            break;
        case 2:
            organizer.OrganizeByType();
            break;
       /* case 3:
            organizer.OrganizeByName();
            break;
        case 4:
            organizer.OrganizeBySize();
            break;
        case 5:
            organizer.OrganizeByDate();
            break;
        case 6:
            organizer.OrganizeByExtension();
            break;
        case 7:
            organizer.ShowStatistics();
            break;
        case 8:
            if (organizer.CreateCategoryFolders()) {
                std::wcout << L"分类文件夹创建成功!\n";
            }
            else {
                std::wcout << L"创建分类文件夹失败!\n";
            }
            break;
        case 9:
            organizer.MoveFilesToCategories();
            break;
        case 0:
            std::wcout << L"感谢使用，再见！\n";
            break;*/
        default:
            std::wcout << L"无效选择，请重新输入！\n";
            break;
        }

        if (choice != 0) {
            Pause();
        }

    } while (choice != 0);

    return app.exec();
}
